package cn.hamm.wecom.module.basic.message;

import cn.hamm.wecom.common.AbstractWeComRequest;
import cn.hamm.wecom.common.WeComResponse;
import cn.hamm.wecom.common.constant.WeComAlias;
import cn.hamm.wecom.common.enums.WeComMsgType;
import cn.hamm.wecom.common.util.json.BooleanToZeroOne;
import cn.hamm.wecom.common.util.json.ZeroOneToBoolean;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

/**
 * <h1>MessageSendRequest</h1>
 *
 * @author Hamm.cn
 * @see <a href="https://developer.work.weixin.qq.com/document/path/90236">发送应用消息</a>
 */
@Getter
@SuppressWarnings("unused")
public class MessageSendRequest extends AbstractWeComRequest<MessageSendRequest.Response, MessageSendRequest> {

    @JsonProperty(WeComAlias.TO_USER)
    private String toUser;

    @JsonProperty(WeComAlias.TO_PARTY)
    private String toParty;

    @JsonProperty(WeComAlias.TO_TAG)
    private String toTag;

    @JsonProperty(WeComAlias.MSG_TYPE)
    private WeComMsgType msgType;

    @JsonProperty(WeComAlias.AGENTID)
    private String agentId;

    @JsonSerialize(using = BooleanToZeroOne.class)
    @JsonDeserialize(using = ZeroOneToBoolean.class)
    private Boolean safe;

    @JsonProperty(WeComAlias.ENABLE_DUPLICATE_CHECK)
    @JsonSerialize(using = BooleanToZeroOne.class)
    @JsonDeserialize(using = ZeroOneToBoolean.class)
    private Boolean enableDuplicateCheck;

    @JsonProperty(WeComAlias.DUPLICATE_CHECK_INTERVAL)
    private Integer duplicateCheckInterval = 1800;

    private Text text;

    public MessageSendRequest setTextCard(TextCard textCard) {
        this.textCard = textCard;
        return this;
    }

    public MessageSendRequest setImage(Image image) {
        this.image = image;
        return this;
    }

    public MessageSendRequest setFile(File file) {
        this.file = file;
        return this;
    }

    public MessageSendRequest setVoice(Voice voice) {
        this.voice = voice;
        return this;
    }

    public MessageSendRequest setVideo(Video video) {
        this.video = video;
        return this;
    }

    public static class Response extends WeComResponse<Response> {
    }
}